package ru.osu.acm.testing.beans;

/**
 * User: Integra
 * Date: 19.08.2009
 * Time: 19:25:43
 */
public class UserBean {
    private PersonBean person;
    private TeamBean team;
    private boolean loggedIn;
    private boolean isadmin;
    private String name;

    public UserBean(PersonBean person, TeamBean team, boolean loggedIn, boolean isadmin) {
        this.person = person;
        this.team = team;
        this.loggedIn = loggedIn;
        this.isadmin = isadmin;
    }

    public boolean isTeam() {
        return team != null;
    }

    public PersonBean getPerson() {
        return person;
    }

    public void setPerson(PersonBean person) {
        this.person = person;
    }

    public TeamBean getTeam() {
        return team;
    }

    public void setTeam(TeamBean team) {
        this.team = team;
    }

    public boolean isLoggedIn() {
        return loggedIn;
    }

    public void setLoggedIn(boolean loggedIn) {
        this.loggedIn = loggedIn;
    }

    public boolean isIsadmin() {
        return isadmin;
    }

    public void setIsadmin(boolean isadmin) {
        this.isadmin = isadmin;
    }

    public String getName() {
        if (person != null && team == null)
            name = person.getUsername();
        else if (person == null && team != null)
            name = team.getLogin();
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getFullName (){
        if (person != null && team == null)
            return person.getName() + " " + person.getSurname();
        return team.getTeamname();    
    }

}
